Division mod $m$
Division in modular arithmetic is more subtle than addition, subtraction, or multiplication. It only works when the number you want to divide by has a multiplicative inverse modulo $m$.
What does division mean mod $m$?
- In ordinary arithmetic, dividing by $b$ means multiplying by $1/b$.
- In modular arithmetic, dividing by $b$ means multiplying by a number $b^{-1}$ such that $$b \cdot b^{-1} \equiv 1 \pmod{m}.$$
- This number $b^{-1}$ is called the multiplicative inverse of $b$ mod $m$.
When does an inverse exist?
- A number $b$ has an inverse mod $m$ if and only if $$\gcd(b, m) = 1.$$
- In other words:
- If $b$ and $m$ share no common factors (other than $1$), division is possible.
- If they share a factor, division is not well‑defined.
Examples
- Example 1: $3^{-1} \pmod{7}$
- Modulus $m = 7$
- $3$ and $7$ are coprime
- $3$ has an inverse mod $7$
- In fact, $3 \cdot 5 = 15 \equiv 1 \pmod{7}$, so $3^{-1} \equiv 5$.
- Example 2: $4^{-1} \pmod{10}$
- Modulus $m = 10$
- $4$ and $10$ share a factor of $2$
- $4$ has no inverse mod $10$
- So expressions like $a/4 \pmod{10}$ do not make sense.
How to compute an inverse (conceptually)
For beginners, it’s enough to know:
- Try small numbers until you find one that works.
- Use the fact that the inverse must satisfy $$b \cdot x \equiv 1 \pmod{m}.$$
Example: Find the inverse of $7$ mod $12$
- Try small $x$:
- $7 \cdot 7 = 49 \equiv 1 \pmod{12}$
- So $7^{-1} \equiv 7$.
Advanced readers can solve the linear diophantine equation: $$ax + my = 1$$
Using division once the inverse is known
To compute $$\frac{a}{b} \pmod{m},$$ rewrite it as $$a \cdot b^{-1} \pmod{m}.$$ Example: Compute $6 / 3 \pmod{7}$
- First find $3^{-1} \equiv 5$
- Then compute $6 \cdot 5 = 30 \equiv 2 \pmod{7}$
- So $6/3 \equiv 2$.
Key takeaways
- Division is not always allowed in modular arithmetic.
- It only works when the divisor has an inverse.
- Inverses exist exactly when the divisor and modulus are coprime.
- When an inverse exists, division becomes multiplication by that inverse.